<!DOCTYPE html>
<html>
  <head>    
      <title>功能投票</title>
      <% include layout/lib.ejs %>
      <link rel="stylesheet" type="text/css" href="/css/functionVote.css" />
  </head>
  <body>

        <% include layout/header.ejs %>

        <!-- <div class="bannerBox">
            <div class="bannerItem" style="background-image:url('/image/ed-13.jpg');"></div>
        </div> -->

        <div class="functionVoteBox">
            <div class="functionVoteBoxMain">
                <div class="functionVoteTitle">
                    <i class="fa fa-handshake-o fa-lg"></i><b>读我：</b><br/><span style="color:#999;float:left;margin-top:5px;margin-bottom:20px;">您可以把您觉得最想让框架加入的功能告诉我们，对于大家都想要实现的方便功能我们会优先加入进新版本之中，再输入之前，尽量首先搜索是否有人已经提议了相关的功能，您可以直接进行投票追加，票数的越高我们也会越优先进行实现,我们会对您提出的需求进行需求的评审，然后合并在投票内容之中，供大家进行投票</span>
                    
                </div>
                <div class="functionVoteTextAreaBox">
                    <div class="functionVoteTextAreaTitle"><i class="fa fa-pencil-square-o fa-lg"></i>您想要增加的功能<span style="color:red;">（尽量精炼的说出来，例如：加入原子层对PDO的支持 or 管理后台加入数据库管理工具）:</span></div>
                    <div class="functionVoteTextAreaContent">
                        <input placeholder="请输入您的需求" id="vName"></input>
                        <div class="codeData" style="margin-top:20px;">
                                <input type="text" id="vCode" style="width:150px;height:57px;outline: none;float:left;margin-right:10px;padding-left:15px;padding-right:15px;border:none;border:1px solid #eee;"
                                    name="code" placeholder="请输入验证码" /> <img id="codeImage" style="position:relative;top:0px;border:1px solid #eee;padding-bottom:5px;"
                                    src="/common/createCode">
                            </div>
                        <div class="tupiaoBtn">提交</div>
                    </div>
                </div>

                <div class="functionVoteContent">
                    <div class="functionVoteContentTitle">
                        <i class="fa fa-bar-chart fa-lg"></i>功能投票列表：
                        <b><em style="font-style: normal;margin-right:10px;padding:5px;color:#999;font-size:12px;position:relative;top:-1px;">我们将会尽力将需求比较靠前的功能进行优先的开发，加入在近期的版本中</em></b>
                        <div class="sousuoBtn" id="allsearch" style="border-left:1px solid #e0e0e0;border-top-right-radius: 5px;border-bottom-right-radius: 5px;" id="searchVote">全部</div>
                        <div class="sousuoBtn" id="searchVote">搜索</div>
                        <input id="searchVoteValue" placeholder="请输入您要搜索的需求关键字"></input>
                    
                      
                    </div>
                    <div class="functionVoteMain">
                        <% if(voteData.length<=0){ %>
                            <div style="color:#999;">暂无功能投票项</div>
                        <% } %>
                        <% for(var i=0;i<voteData.length;i++){ %>
                                <div class="functionVoteMainItem">
                                        <div class="functionVoteMainItemTitle"><b><%- (i+1) %>.</b> <%- voteData[i].fv_name %></div>
                                        <div class="functionVoteMainItemContent">
                                            <div class="functionVoteMainItemProgressBox">
                                                <div class="functionVoteProgress" style="width:<%- voteData[i].percentage %>%"></div>
                                            </div>
                                            <div class="functionVoteMainItemProgressText">
                                                <div class="voteCount"><%- voteData[i].fv_vote_count %>票</div>
                                                <div class="voteActionBox">
                                                    <span id="<%- voteData[i].fv_id %>"><i class="fa fa-thumbs-o-up fa-lg"></i>追加投票</span>
                                                    <% if(voteData[i].fv_status == 0){ %>
                                                        <b class="voteUsed" style="color:#999;">未开发</b>
                                                    <% }else{ %>
                                                        <b class="voteUsed">未开发</b>
                                                    <% } %>
                                                </div>
                                            </div>
                                        </div>
                                </div>
                        <% } %>    
                    </div>
                </div>
            </div>
        </div>

        <% include layout/footer.ejs %>
  </body>
  <script>
        $("#codeImage").click(function(){
            $(this).attr("src","/common/createCode?random=" + Math.random())
        });

        $("#allsearch").click(function(){
            $(".functionVoteMainItem").show();
            $('#searchVoteValue').val("");
        });

        $("#searchVote").click(function(){
            $(".functionVoteMainItem").hide();
            $(".functionVoteMainItem .functionVoteMainItemTitle").filter(":contains('" + ($('#searchVoteValue').val()) + "')").parent().show();
        });

        $(".voteActionBox span").click(function(){

            //查看用户是否登录
            if (!USER.isLogin()) {
                POP.warning("请先登录，在进行该操作");
                return;
            }

            var fvid = $(this).attr("id");
            var uid  = USER.getUserId();

            var params = {
                fv_id : fvid,
                u_id  : uid
            }

            POP.startLoading();

            HTTP.post("/user/additionalFunctionVote", params, (rs) => {

                POP.endLoading();
                POP.success("提示信息", "恭喜您，投票成功");

                setTimeout(() => {
                    location.reload();
                }, 1500);

            })


        }); 

        $(".tupiaoBtn").click(function(){


            //查看用户是否登录
            if (!USER.isLogin()) {
                POP.warning("请先登录，在进行该操作");
                return;
            }

            var vName = $("#vName").val();
            var vCode = $("#vCode").val();

            if (str_trim(vName).length <= 0) {
                POP.warning("验证提示", "需求内容不能为空");
                return;
            }

            var params = {
                fv_name: vName,
                v_code: vCode
            }

            POP.startLoading();

            HTTP.post("/user/addFunctionVote", params, (rs) => {

                POP.endLoading();
                POP.success("提示信息", "恭喜您，功能投票提交成功");

                setTimeout(() => {
                    location.reload();
                }, 1500);

            })

        })


  </script>
</html>